﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace ly.Web.Admin
{
    public partial class newsManager : System.Web.UI.Page
    {
        ly.BLL.news newsBLL = new BLL.news();
        ly.Model.news newModel = new Model.news();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
            }
        }

        private void BindData()
        {

            //string username = "";
            //string strwhere = "where Type in('老师','普通用户' ) username like '%" + username + "%'";
            string strwhere = "";
            DataTable dt = newsBLL.GetList(strwhere).Tables[0];
            PagedDataSource ps = new PagedDataSource();
            ps.DataSource = dt.DefaultView;
            ps.AllowPaging = true;
            rptWork.DataSource = ps;
            rptWork.DataBind();
        }
        public void imbtnUpdate_Command(object sender, CommandEventArgs e)
        {
            int id = Convert.ToInt32(e.CommandArgument);
            Response.Redirect(string.Format("editNews.aspx?id={0}", id));

        }

        //图片按钮删除事件
        public void imbtnDel_Command(object sender, CommandEventArgs e)
        {
            int id = Convert.ToInt32(e.CommandArgument);
            newsBLL.Delete(id);
            DataSet ds = newsBLL.GetList("");
            rptWork.DataSource = ds;
            rptWork.DataBind();

        }

    }
}